// 测试继承

let x ;

class Animal {
    protected type: string;
    constructor(type: string){
        this.type = type ;
        x = this ;
    }
    toString():string {
        return `这是一只动物`;
    }
}

class Beast extends Animal {
    private _name: string;
    constructor( name: string ){
        super( '兽类' );
        this._name = name ;
    }
    get name(): string{
        console.log( 'Beast : get name()' );
        return this._name;
    }
    set name( value: string ) {
        console.log( 'Beast : set name( value )' );
        this._name = value ;
    }
}

class Bear extends Beast {
    constructor( name: string ){
        super( name );
    }
}


const b = new Bear( '熊二' );
console.log( b.hasOwnProperty( 'type' ) ); // true
console.log( b.hasOwnProperty( '_name' ) ); // true
console.log( x === b ); // true

console.log( b.name );

b.name = '熊大' ;

console.log( b.name );

console.log( b );
console.log( b.hasOwnProperty( 'toString' ) ); // false
console.log( b.toString() );